package com.ykh.controller;

import com.ykh.pojo.po.User;
import com.ykh.pojo.vo.ErrorCode;
import com.ykh.pojo.vo.Result;
import com.ykh.service.MessageServie;
import com.ykh.util.UserThreadLocal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YKH
 * Date: 2023-06-08
 * Time: 13:31
 */
@RestController
@RequestMapping("message")
public class MessageController {
    @Autowired
    MessageServie messageServie;
    /**
     * 获取自己的消息列表
     * @param
     * @return
     */
    @PostMapping("list")
    public Result getMessage() {
        User user = UserThreadLocal.get();
        if(user == null){
            return Result.fail(ErrorCode.NO_LOGIN.getCode(), ErrorCode.NO_LOGIN.getMsg());
        }
        return messageServie.getMessageList(user);
    }

    /**
     * 视频发布成，推送消息给粉丝
     * @param
     * @return
     */
    @PostMapping("video")
    public Result addVideoMessage(@RequestParam Integer videoId) {
        User user = UserThreadLocal.get();
        if(user == null){
            return Result.fail(ErrorCode.NO_LOGIN.getCode(), ErrorCode.NO_LOGIN.getMsg());
        }
        return messageServie.addVideoMessage(videoId, user);
    }


//    /**
//     * 关注成功，推送消息给被关注的用户
//     * @param
//     * @return
//     */
//    @PostMapping("focus")
//    public Result addFocusMessage(@RequestParam String acceptUserId) {
//        User user = UserThreadLocal.get();
//        if(user == null){
//            return Result.fail(ErrorCode.NO_LOGIN.getCode(), ErrorCode.NO_LOGIN.getMsg());
//        }
//        return messageServie.addFocusMessage(acceptUserId, user);
//    }
}
